import socket
IP = '127.0.0.1'
PORT = 1953
address =(IP,PORT)
cli = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
cli.connect(address)
while True:
    input_msg = input("请输入")
    cli.send(input_msg.encode('utf-8'))
    # hello 是unicode32字符集

    # 变成utf-8进行传输
    # python3默认使用的是utf-8的加密方式
    # 'hello'.encode('utf-8')等同于b'hello',都是将'hello'加密后转成二进制字符

    msg = cli.recv(1024)
    msg = msg.decode('utf8')

    if msg == 'connect is closed':
        cli.close()
        print(msg)
        break

    # cli.close()